/**
 * 
 */
package com.lanswon.qzsmk.service.systemManageService.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lanswon.qzsmk.base.BlackListContants;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.base.HttpContants;
import com.lanswon.qzsmk.dao.BlackListGenMapper;
import com.lanswon.qzsmk.service.systemManageService.BlackListGenManageService;
import com.lanswon.qzsmk.vo.BlackListGenVo;
import com.lanswon.qzsmk.vo.ResultStatus;
import com.lanswon.qzsmk.vo.ResultVo;

/**
 * @author sun
 *
 */
@Service
public class BlackListGenManageServiceImpl implements BlackListGenManageService {

	@Autowired
	BlackListGenMapper blgm;
	
	@Override
	public ResultVo showBlackListGen(BlackListGenVo b) {
		
		ResultVo rv = new ResultVo();
		ResultStatus rs =new ResultStatus();
		
		rs.setCode(HttpContants.RETURN_SUCCESS);
		rs.setMessage("返回成功");
		
		rv.setResultStatus(rs);
		
		List<BlackListGenVo> lb = blgm.queryAllBlackListGen(b);
		List<BlackListGenVo> list = new ArrayList<>();
		for(BlackListGenVo v:lb){
			v.setCurStatusName(BlackListContants.getBlackStatus(v.getCurStatus()));
			v.setBlackModeName(BlackListContants.getBlacMode(v.getBlackMode()));
			if(StringUtils.isEmpty(v.getBlReason())){
				v.setBlreasonName(v.getBlReason());
			}else{
				v.setBlreasonName(BlackListContants.getBlackReason(v.getBlReason()));
			}
			
			v.setReleaseSysName(BlackListContants.getBlacPublishingSystem(v.getReleaseSys()));
			list.add(v);
		}
		
		int totalCount = blgm.queryAllBlackListGenCount(b);

		DwzPage<BlackListGenVo> dp = new DwzPage<>(b.getCurrentPage(), b.getNumPerPage(), totalCount);
		dp.setList(list);
		
		rv.setServiceObject(dp);
		return rv;
	}

}
